home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / index.doc < prev    next >
Text File  |  1995-04-22  |  2KB  |  66 lines

  1.  
  2.                                      INDEX 
  3.  
  4.  
  5.    INDEX is a high-performance BASIC subroutine to search a string for a 
  6. substring. It works much like the PL/I INDEX function. (See DEMONSTRATION 
  7. below.) 
  8.  
  9.    IMPORTANT NOTES 
  10.  
  11.    1.  INDEX is fully self-relocatable, so it may be moved anywhere in memory. 
  12.    2.  INDEX is useful for scanning a string for certain characters(s). Note 
  13. that the string to be searched can also be a substring of a longer string. 
  14.    3.  The search argument substring will normally be shorter than the string to 
  15. be searched. 
  16.  
  17.    CALLING 
  18.  
  19. RETURNCODE=USR(INDEX, STRADR, SUBADR, STRLEN, ADRLEN) 
  20.  
  21.    INDEX:   The address of the INDEX subroutine [usually ADR(INDEXSTRING$)]. 
  22.    STRADR:  Address of the string to be searched [usually ADR(DATASTRING1$)]. 
  23.    SUBADR:  Address of the search substring [usually ADR(DATASTRING2$)]. 
  24.    STRLEN:  Length of the string to be searched [usually LEN(DATASTRING1$)]. 
  25.    SUBLEN:  Length of the search substring [usually LEN(DATASTRING2$)]. 
  26.  
  27.    RETURN CODES 
  28.  
  29.    0   Substring not found. 
  30.    >0  Leftmost position of the substring in string (first position is 1). 
  31.  
  32.    DEMONSTRATION 
  33.  
  34.    INDEX.BIN is a simple tokenized BASIC (binary) program which will demonstrate 
  35. the INDEX subroutine. You may type both a string and a search substring. For 
  36. example the string "NOW IS THE TIME" will give a return code of 5 when searched 
  37. with "IS". 
  38.  
  39.    USE 
  40.  
  41.    To use the subroutine, just transfer the statements 900-904 to your own 
  42. program (you could do a LIST "D:TEMP",900,904 from the demo followed by an ENTER 
  43. "D:TEMP" into your own program); of course, you can renumber the statements as 
  44. necessary. Remember to call the subroutine once at the beginning of your program 
  45. to set it up. 
  46.  
  47.    -John Navas [72645,1070] 
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.